// 用户请求模块
import request from '@/utils/request'

// 登录请求
export const loginAPI = (data) => {
  return request({
    method: 'POST',
    url: '/v1_0/authorizations',
    data: data
  })
}
// 获取验证码
export const sendSmsAPI = (mobile) => {
  return request({
    method: 'GET',
    url: `/v1_0/sms/codes/${mobile}`
  })
}

// 获取用户自己信息
export const getUserInfoAPI = () => {
  return request({
    method: 'GET',
    url: '/v1_0/user'
  })
}

// 获取用户频道
export const getUserTabAPI = () => {
  return request({
    method: 'GET',
    url: '/v1_0/user/channels'
  })
}

// 获取所有频道
export const getAllHomeTabAPI = () => {
  return request({
    method: 'GET',
    url: '/v1_0/channels'
  })
}

// 添加到用户频道
export const addUserChannelAPI = (channels) => {
  return request({
    method: 'PATCH',
    url: '/v1_0/user/channels',
    data: {
      channels: [channels]
    }
  })
}

// 删除用户指定频道
export const delUserChannelAPI = (channelid) => {
  return request({
    method: 'DELETE',
    url: `/v1_0/user/channels/${channelid}`
  })
}

// 关注用户
export const addFollowAPI = (target) => {
  return request({
    method: 'POST',
    url: '/v1_0/user/followings',
    data: {
      target
    }
  })
}

// 取消关注用户
export const delFollowAPI = (target) => {
  return request({
    method: 'DELETE',
    url: `/v1_0/user/followings/${target}`
  })
}

// 获取当前用户的个人资料
export const getUserProfileAPI = () => {
  return request({
    method: 'GET',
    url: '/v1_0/user/profile'
  })
}

// 修改用户资料
export const upUserProfileAPI = data => {
  return request({
    method: 'PATCH',
    url: '/v1_0/user/profile',
    data
  })
}

// 编辑用户照片资料
export const upUserPhotoAPI = data => {
  return request({
    method: 'PATCH',
    url: '/v1_0/user/photo',
    data
  })
}
